﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="/WF/Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/WF/Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
    <link href="/WF/Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/WF/Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
    <link href="/WF/Style/skin/font/iconfont.css" rel="stylesheet" type="text/css" />
    <!--通用js-->
    <script src="/WF/Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="/WF/Scripts/QueryString.js" type="text/javascript"></script>
    <script src="/WF/Scripts/config.js" type="text/javascript"></script>
    <script src="/WF/Comm/Gener.js" type="text/javascript"></script>
    <script src="../../WF/CCForm/JS/wpslib/project.js"></script>
    <script src="../../WF/CCForm/JS/wpslib/wpsjsrpcsdk.js"></script>
    <link href="css/icons.css" rel="stylesheet" />
    <script type="text/javascript">

        var workID = GetQueryString("WorkID"); //workid 子线程的ID
        $(function () {

            //传入数据调用ajax. 返回查询犯人的接口.
            var data = "";

            var flowNo = "001";
            var nodeID = GetQueryString("FK_Node");
            if (nodeID.indexOf('1') == 0)
                flowNo = '001';
            if (nodeID.indexOf('2') == 0)
                flowNo = '002';
            
            //获得.
            var ens = new Entities("BP.JianYu.Fanrens");

            if (flowNo == '001')
                ens.Retrieve("WorkIDOf001", workID, "DelFlag", 0);
            else if (flowNo == '002')
                ens.Retrieve("WorkIDOf002", workID, "DelFlag", 0);
            else if (flowNo == '003') {
                //获取父workID
                var sql = "select PWorkID,FenJianQuNo from  ND3Rpt  WHERE OID=" + workID;
                var jsonstr = DBAccess.RunSQLReturnTable(sql);
                ens.Retrieve("WorkIDOf001", jsonstr[0].PWorkID, "FenJianQuNo", jsonstr[0].FenJianQuNo,"DelFlag", 0);
            } else if (flowNo == '004') {
                //获取父workID
                var sql = "select PWorkID,JianQuNo from  ND4Rpt  WHERE OID=" + workID;
                var jsonstr = DBAccess.RunSQLReturnTable(sql);
                ens.Retrieve("WorkIDOf001", jsonstr[0].PWorkID, "FenJianQuNo", jsonstr[0].JianQuNo, "DelFlag", 0);
            }

            var jianqus = new Entities("BP.JianYu.JianQus");
            jianqus.RetrieveAll();

            var html = "<table class='table table-bordered table - hover' >";
            html += "<caption>罪犯列表，合计：" + ens.length + "名.</caption>";
            html += "<tr>";
            html += "<th>编号 CRID</th>";
            html += "<th width='3%'>姓名</th>";
            html += "<th>年龄</th>";
            html += "<th>监区</th>"; //监区
            html += "<th>分监区</th>"; //分监区
            html += "<th>入监日期</th>";
            html += "<th>罪名</th>";
            html += "<th>罪犯类型</th>";
            html += "<th>罪犯类别</th>";
            html += "<th>原判刑期</th>";
            html += "<th>现刑期</th>";
            html += "<th>减刑间隔</th>";
            html += "<th>减刑幅度</th>";
            html += "<th>表扬次数</th>";
            html += "<th>年累计分</th>";
            html += "<th>是否老病残</th>";
            html += "<th>是否立功</th>";
            html += "<th>是否重大立功</th>";
            html += "<th>是否职务犯</th>";
            html += "<th>操作</th>";   //分监区
            html += "</tr>";

            for (var idx = 0; idx < jianqus.length; idx++) {
                var jq = jianqus[idx];

                for (var i = 0; i < ens.length; i++) {

                    var en = ens[i];
                    if (en.JianQuNo != jq.No)
                        continue;
                    html += "<tr>";
                    html += "<th colsapn=5>" + jq.No + " - " + jq.Name + "</th>";
                    html += "</tr>";
                    var lbc = "否";
                    if (en.ShiFouLBC == 1)
                        lbc = "是";
                    var lg = "否";
                    if (en.ShiFouLG == 1)
                        lg = "是";
                    var zdlg = "否";
                    if (en.ShiFouZDLG == 1)
                        zdlg = "是";
                    var zwf = "否";
                    if (en.zwf == 1)
                        zwf = "是";
                    html += "<tr>";

                    html += "<td>" + en.CRID + "</td>";
                    html += "<td> <a href=\"javascript:OpenIt('" + en.MyPK + "','" + en.WorkIDOf008 + "')\" >" + en.Name + "</a></td>";
                    html += "<td>" + en.Age + "</td>";
                    html += "<td>" + en.JianQuNo + en.JianQuNoText + "</td>";  //监区
                    html += "<td>" + en.FenJianQuNo + en.FenJianQuNoText + "</td>"; //分监区

                    html += "<td>" + en.DTComein + "</td>";
                    html += "<td>" + en.ZuiMing + "</td>";
                    html += "<td>" + en.ZuiFanLX + "</td>";
                    html += "<td>" + en.ZuiFanLB + "</td>";
                    html += "<td>" + en.YuanPanXQ + "</td>";
                    html += "<td>" + en.XianXQ + "</td>";
                    html += "<td>" + en.JianXingJG + "</td>";
                    html += "<td>" + en.JianXingFD + "</td>";
                    html += "<td>" + en.BiaoYangCS + "</td>";
                    html += "<td>" + en.NianLeiJF + "</td>";
                    html += "<td>" + lbc + "</td>";
                    html += "<td>" + lg + "</td>";
                    html += "<td>" + zdlg + "</td>";
                    html += "<td>" + zwf + "</td>";
                    html += "<td>"; //分监区
                    if (nodeID == "202" || nodeID == "203" )
                        html += " <a href=\"javascript:Del('" + en.MyPK + "','" + en.WorkIDOf008 + "')\" ><img src='../../WF/Img/Btn/Delete.png'> 删除</a> ";

                   // if (nodeID == 111)
                    //    html += "<a href=\"javascript:JianXingBook('" + en.MyPK + "')\" ><img src='../../WF/Img/FileType/doc.gif'>减刑建议书</a>";

                   // if (flowNo == '002')
                    //    html += "<a href=\"javascript:JiFenTable('" + en.WorkIDOf008 + "','" + en.MyPK + "','" + en.CRID + "')\" ><img src='../../WF/Img/FileType/doc.gif'>计分考核表</a> ";

                    html += "</td>"; //分监区

                    html += "</tr>";
                }
            }
            html += "</table>";
            $("#docs").html(html);

            ////console.log(html);
            //var handler = new HttpHandler("BP.JianYu.AppHandler");
            //handler.AddPara("Ens", data);
        });
        //生成计分考核表
        function JiFenTable(workidFanRen,mypk,crid) {

            if (workidFanRen == 0) {
                var en = new Entity("BP.JianYu.Fanren", mypk);
                workidFanRen = en.DoMethodReturnString("DoMakeWorkIDOfFanren");
            }
            //获取中间表数据放入表单表中
            var handler = new HttpHandler("BP.JianYu.AppHandler");
            handler.AddUrlData();
            handler.AddPara("CRID", crid);
            handler.AddPara("WorkidFanRen", workidFanRen);
            handler.DoMethodReturnString("DoJiFenZongHeBiao");

            var url = "/WF/CCForm/Frm.htm?FK_Flow=002&FK_Node=201&WorkID=" + workidFanRen +"&FrmID=Frm_JiFenKaoHeZongHeBiao&FK_MapData=Frm_JiFenKaoHeZongHeBiao&OpenWPS=1";
           // if (nodeID == 202)
             //   url += "&FrmID=xxxxxx";
            window.open(url);

            

        }
        /* 调用的方法 */
        function fillTemplate() {
            // var filePath = GetDemoPath("样章2.docx");

            //var filePath = prompt("请输入打开文件路径（本地或是url）：", GetDemoPath("样章.docx"))
            // var uploadPath = "BP.WF.Dev2Interface.UploadFile"
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("WpsFrm_Init");
            if (data.indexOf('err@') == 0) {
                alert('装载表单出错,请查看控制台console,或者反馈给管理员.' + data);
                console.log(data);
                return;
            }
            var url1 = document.location.host;

            wpsTempURL = document.location.protocol + "//" + url1 + data;
            var uploadPath = dynamicHandler + "?DoType=HttpHandler&DoMethod=WpsFrm_SaveFile&HttpHandlerName=BP.WF.HttpHandler.WF_CCForm&FrmID=" + frmID + "&WorkID=" + oid;
            var uploadFieldName = "fileField";

            var invokeParam = {
                "fileName": wpsTempURL,
                "templateDataUrl": wpsData,
                "childDatas": childDatas,

                "uploadPath": uploadPath, // 保存文档上传接口
                //"fileName": filePath,
                "uploadFieldName": uploadFieldName,
                "userName": "东方不败"

            }; //根据需求任意定义
            WpsInvoke.InvokeAsHttp(
                projInfo.type,
                projInfo.name, //wps加载项的名字，在实际项目中写上对应的名字
                "OpenDoc", //要调用的在wps加载项中的函数名
                JSON.stringify(invokeParam), //调用的在wps加载项中的函数要传递的数据，是一个json对象，根据业务系统需求任意定义
                callbackFunc, //回调函数，wps加载项中InvokeFromSystemDemo这个函数的返回值作为这个函数的参数
                true) //设置wps是否显示到最前面来

            //OpenDoc(param);
        }
        function OpenIt(mypk, workidFanRen) {

            var en = new Entity("BP.JianYu.Fanren", mypk);
            workidFanRen = en.DoMethodReturnString("DoMakeWorkIDOfFanren");

            var url = "/WF/MyView.htm?FK_Flow=008&WorkID=" + workidFanRen;
           // if (nodeID == 202)
              //  url += "&FrmID=xxxxxx";
            
            window.open(url);
        }

        //打开减刑建议书.
        function JianXingBook(mypk) {

            var en = new Entity("BP.JianYu.Fanren", mypk);
            var url = en.DoMethodReturnString("DoJianXing");

            url = url.replace('url@', '');
            window.open(url);
        }

        //逻辑删除，改变状态
        function Del(id) {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var en = new Entity("BP.JianYu.Fanren", id);
            en.DelFlag = 1;
            en.Update();
            window.location.href = window.location.href;
        }
        //保存查询结果.
        function AddNew() {

            var webUser = new WebUser();
            var name = window.prompt('请输入编号', "001");

            var en = new Entity("BP.JianYu.Fanren");
            en.FenJianQuNo = webUser.FK_Dept;
            en.MyPK = workID + name;
            en.Name = name;
            en.WorkIDOfSubthread = workID;
            en.WorkID = fid;
            en.Insert();

            window.location.href = window.location.href;
        }

        function Save() {
            return true;
        }
    </script>
</head>
<body>
    <form>

        <div id="docs">
        </div>

    </form>

</body>
</html>
